package org.example.java8.stream;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;

/**
 * @author 夏焰波
 * @date 2020-07-13 1:34
 */
public class StreamMatch {
    public static void main(String[] args) {
        List<Integer> list = Arrays.asList(1, 2, 3, 4, 5, 6, 7);
        Stream<Integer> stream = list.stream();
        //都满足条件
        boolean b = stream.allMatch(integer -> integer > 10);
        System.out.println(b);

        Integer[] integers = {1, 2, 3, 4, 5, 6, 7};
        Stream<Integer> stream1 = Arrays.stream(integers);
        //只要有一个满足条件
        boolean b1 = stream1.anyMatch(integer -> integer > 6);
        System.out.println(b1);

        Stream<Integer> stream2 = Arrays.stream(integers);
        //都不满足条件
        boolean b2 = stream2.noneMatch(integer -> integer < 0);
        System.out.println(b2);
    }
}
